Ext.define('appmod.view.role.authorization.ModuleList', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.authmodulelistpanel',
	requires:[
		'Ext.ux.CheckColumn',
		'Ext.selection.CellModel'
	],
    initComponent: function() {
        var me = this;
		
		// --- add event ---
		me.addEvents({
			subfunexec:true
		});

        Ext.applyIf(me, {
            columns: [
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'name',
                    text: '模块名',
					width: 100,
					sortable :false
                },
                {
                    xtype: 'gridcolumn',
                    dataIndex: 'version',
                    text: '版本',
					width: 100,
					sortable :false
                },				
                {
                	xtype: 'datecolumn',
                    dataIndex: 'releaseDate',
                    text: '发布日期',
					width: 100,
					format:'Y-m-d',
					sortable :false
                },
				{
            		header: '允许访问',
            		dataIndex: 'acl',
            		width: 60,
            		field: {
                		xtype: 'combobox',
                		typeAhead: true,
                		triggerAction: 'all',
                		selectOnTab: true,
						editable :false,
                		store: Ext.create('Ext.data.ArrayStore', {
							storeId:'selectId',
							fields:['label' , 'value'],
							data:[
								['允许','access'],
								['禁止','deny'],
								['未设定','']
							]
						}),
						displayField:'label',
						valueField: 'value', 
                		lazyRender: true,
                		listClass: 'x-combo-list-small'
            		},
					renderer:function(value) {
						if (value == 'access') {
							return '允许';
						} else if (value == 'deny') {
							return '禁止';
						} else {
							return '未设定';
						}						
					}					
        		},
				{
					text: '刷新子功能',
		            width: 70,
		            menuDisabled: true,
		            xtype: 'actioncolumn',
		            tooltip: '刷新子功能',
		            align: 'center',
					iconCls:'x-action-edittask',
		            handler: function(grid, rowIndex, colIndex, actionItem, event, record, row) {
		              // --- fire event ---
			  
					  me.fireEvent('subfunexec',grid , record , actionItem , {
					  	rowIndex : rowIndex,
						colIndex : colIndex
					  } , event);
		            }
				}				
            ],
			selModel:{
				selType:'checkboxmodel'
			},
			plugins: [
				Ext.create('Ext.grid.plugin.CellEditing', {
					clicktoEdit:2
    			})
			],
            viewConfig: {

            },
			dockedItems: [
			{
				xtype: 'toolbar',
				dock: 'top',
				items: [
				{
					xtype: 'button',
				    text: '保存模块授权',
					action:'auth'
				}
				]
			}
			]			
        });

        me.callParent(arguments);
    }
});